const context = require.context('./dir', true, /\.js$/)

export default {
    install(Vue, options) {
        if (options && options.directives) {
            let directives = options.directives
            directives.forEach(v => {
                let arr = context.keys()
                let contextFilter = arr.filter(key => context(key).default.name === v)
                console.log('当前注册的全局指令有：', contextFilter)
                contextFilter.forEach(v => {
                    Vue.directive(context(v).default.name, context(v).default)
                })
            })
        } else {
            context.keys().forEach(v => {
                Vue.directive(context(v).default.name, context(v).default)
            })
            console.log('当前注册的全局指令有：', context.keys().join(','))
        }
    }
}
